--[[========================================================
	INCLUDES & CLIENT FILES
========================================================]]--

AddCSLuaFile( "shared.lua" )
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "config/config.lua" )
AddCSLuaFile( "helpers/date_time.lua" )
AddCSLuaFile( "helpers/sanity_checks.lua" )
AddCSLuaFile( "helpers/useful.lua" )
AddCSLuaFile( "helpers/color_helper.lua" )
AddCSLuaFile( "helpers/math_helper.lua" )
AddCSLuaFile( "helpers/net_helper.lua" )
AddCSLuaFile( "debug/debug.lua" )
AddCSLuaFile( "view/cl_calc_view.lua" )
AddCSLuaFile( "view/cl_crosshair.lua" )
AddCSLuaFile( "input/input.lua" )
AddCSLuaFile( "network/server_to_client.lua" )
AddCSLuaFile( "extensions/player_extension.lua" )
AddCSLuaFile( "vgui/fonts.lua" )
AddCSLuaFile( "vehicles/test_drive.lua" )
AddCSLuaFile( "timer.lua" )
AddCSLuaFile( "class.lua" )
AddCSLuaFile( "helpers/sql_helper.lua" )
AddCSLuaFile( "sql/create_db.lua" )
AddCSLuaFile( "sql/delete_db.lua" )
AddCSLuaFile( "sql/manage_data.lua" )
AddCSLuaFile( "classes/field_info.lua" )
AddCSLuaFile( "classes/sound_info.lua" )
AddCSLuaFile( "classes/activity_info.lua" )
AddCSLuaFile( "classes/damage_info.lua" )
AddCSLuaFile( "classes/view_transform_info.lua" )
AddCSLuaFile( "classes/object_type.lua" )
AddCSLuaFile( "classes/weapon.lua" )
AddCSLuaFile( "classes/firemode.lua" )
AddCSLuaFile( "classes/weapon_firemode.lua" )
AddCSLuaFile( "sql/test_db.lua" )
AddCSLuaFile( "classes/test_classes.lua" )

include( "network/server_to_client.lua" )
include( "helpers/sql_helper.lua" )
include( "sql/manage_data.lua" )
include( "shared.lua" )
include( "sql/create_db.lua" )
include( "sql/delete_db.lua" )
include( "sql/test_db.lua" )


--[[========================================================
	SERVER RESOURCES
========================================================]]--

--[[----------------------------------------------------]]--
--[[	Available player models							]]--
--[[----------------------------------------------------]]--
GM.PLAYER_MODELS = {
	"models/player/arctic.mdl",
	"models/player/gasmask.mdl"
}

--[[----------------------------------------------------]]--
--[[	Precaches a list of models						]]--
--[[----------------------------------------------------]]--
local function LoadModels( tab )
  for k,v in pairs( tab ) do
    util.PrecacheModel( v )
  end
  DEBUG:Msg( "Player models loaded" )
end

--[[========================================================
	GAMEMODE EVENTS
========================================================]]--

--[[----------------------------------------------------]]--
--[[	Initialize the server-side only parts			]]--
--[[----------------------------------------------------]]--
function GM:Initialize()

	--	Load config files
	self:LoadConfigFiles()
	
	--	Precache models
	LoadModels( self.PLAYER_MODELS )
	
	--	Precache network messages
	util.AddNetworkString( "TestNetMsg" )
	
	--	Debug
	DEBUG:Msg( self.Name .. " has been initialized" )
	
end

--[[----------------------------------------------------]]--
--[[	A player respawns								]]--
--[[----------------------------------------------------]]--
function GM:PlayerSpawn( ply )

	-- Randomly select a player model
	ply:SetModel( table.Random( self.PLAYER_MODELS ) )
	
	--	Give default weapons to player
	ply:StripWeapons()
	ply:StripAmmo()
	
	--	Set speed ratios
	ply:SetRunSpeed( 200 )
	ply:SetWalkSpeed( 100 )
	
end